<template>
  <div class="header-wrap" :style="asideStyle">
    <div class="left">
      <el-icon class="collapse-icon" @click="toggleCollage">
        <component :is="globalStore.isCollapse ? 'expand' : 'fold'"></component>
      </el-icon>
    </div>
    <div class="right">
      <!-- <div class="user-info">
        <span class="user-name">Admin</span>
        <img src="@/assets/avatar.gif" alt="">
      </div> -->

      <el-dropdown size="default">
        <span class="el-dropdown-link">
          <div class="user-info">
            <span class="user-name">Admin</span>
            <img src="@/assets/images/avatar.gif" alt="" />
          </div>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>
              <el-icon><Edit /></el-icon>
              修改密码
            </el-dropdown-item>
            <el-dropdown-item divided>
              <el-icon><SwitchButton /></el-icon>
              退出
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup>
import { computed } from "vue";
import { useGlobalStore } from "@/store/modules/global.js";
import config from "@/layouts/config.js";

const globalStore = useGlobalStore();
/* 动态样式 */
const asideStyle = computed(() => ({
  height: config.headerHeight,
}));

function toggleCollage() {
  globalStore.setGlobalState("isCollapse", !globalStore.isCollapse);
}
</script>
<style lang="scss" scoped>
.header-wrap {
  box-sizing: border-box;
  border-bottom: 1px solid $border-color;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .collapse-icon {
    font-size: 22px;
  }
  .user-info {
    display: flex;
    align-items: center;
    img {
      border-radius: 999px;
      margin-left: 20px;
      width: 40px;
      height: 40px;
    }
    .user-name {
      font-size: 16px;
      color: #333;
    }
  }
}
</style>
